package com.asset.dispoal.extension.strategy.command;

import com.asset.dispoal.extension.domain.dto.RolePermissionDTO;
import com.asset.dispoal.extension.strategy.BaseDataPowerStrategyServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.strategy.StrategyHandlerParam;
import tech.mhuang.pacebox.core.strategy.StrategyHandlerResult;

import java.util.Collections;
import java.util.List;

/**
 * 自己权限
 *
 * @author mhuang
 * @since 1.0.0
 */
@Component
@Slf4j
public class OwnDataPowerStrategyServer implements BaseDataPowerStrategyServer {

    @Override
    public StrategyHandlerResult<String> strategy(StrategyHandlerParam<RolePermissionDTO> strategyHandlerParam) {
        RolePermissionDTO dto = strategyHandlerParam.getData();
        String sqlHeader = "select 5 from sys_user u " +
                " where u.id =" + dto.getCarry() +
                " and u.id='" + dto.getUserId() + "'";
        return new StrategyHandlerResult<>(true, sqlHeader);
    }

    @Override
    public List<String> event() {
        return Collections.singletonList("5");
    }
}
